// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
//
// ███╗   ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
// ████╗  ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
// ██╔██╗ ██║██║   ██║   ██║   ██║██║     █████╗
// ██║╚██╗██║██║   ██║   ██║   ██║██║     ██╔══╝
// ██║ ╚████║╚██████╔╝   ██║   ██║╚██████╗███████╗
// ╚═╝  ╚═══╝ ╚═════╝    ╚═╝   ╚═╝ ╚═════╝╚══════╝
// ------------------------------------------------
//
// This file is automatically generated.
// Please do not edit these files manually.
//
// ------------------------------------------------

#nullable restore

using Elastic.Clients.Elasticsearch.Serverless.Fluent;
using Elastic.Clients.Elasticsearch.Serverless.Serialization;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text.Json;
using System.Text.Json.Serialization;

namespace Elastic.Clients.Elasticsearch.Serverless.MachineLearning;

public sealed partial class ClassificationInferenceOptions
{
	/// <summary>
	/// <para>
	/// Specifies the number of top class predictions to return. Defaults to 0.
	/// </para>
	/// </summary>
	[JsonInclude, JsonPropertyName("num_top_classes")]
	public int? NumTopClasses { get; set; }

	/// <summary>
	/// <para>
	/// Specifies the maximum number of feature importance values per document.
	/// </para>
	/// </summary>
	[JsonInclude, JsonPropertyName("num_top_feature_importance_values")]
	public int? NumTopFeatureImportanceValues { get; set; }

	/// <summary>
	/// <para>
	/// Specifies the type of the predicted field to write. Acceptable values are: string, number, boolean. When boolean is provided 1.0 is transformed to true and 0.0 to false.
	/// </para>
	/// </summary>
	[JsonInclude, JsonPropertyName("prediction_field_type")]
	public string? PredictionFieldType { get; set; }

	/// <summary>
	/// <para>
	/// The field that is added to incoming documents to contain the inference prediction. Defaults to predicted_value.
	/// </para>
	/// </summary>
	[JsonInclude, JsonPropertyName("results_field")]
	public string? ResultsField { get; set; }

	/// <summary>
	/// <para>
	/// Specifies the field to which the top classes are written. Defaults to top_classes.
	/// </para>
	/// </summary>
	[JsonInclude, JsonPropertyName("top_classes_results_field")]
	public string? TopClassesResultsField { get; set; }

	public static implicit operator Elastic.Clients.Elasticsearch.Serverless.Aggregations.InferenceConfig(ClassificationInferenceOptions classificationInferenceOptions) => Elastic.Clients.Elasticsearch.Serverless.Aggregations.InferenceConfig.Classification(classificationInferenceOptions);
	public static implicit operator Elastic.Clients.Elasticsearch.Serverless.MachineLearning.InferenceConfigCreate(ClassificationInferenceOptions classificationInferenceOptions) => Elastic.Clients.Elasticsearch.Serverless.MachineLearning.InferenceConfigCreate.Classification(classificationInferenceOptions);
	public static implicit operator Elastic.Clients.Elasticsearch.Serverless.MachineLearning.InferenceConfigUpdate(ClassificationInferenceOptions classificationInferenceOptions) => Elastic.Clients.Elasticsearch.Serverless.MachineLearning.InferenceConfigUpdate.Classification(classificationInferenceOptions);
}

public sealed partial class ClassificationInferenceOptionsDescriptor : SerializableDescriptor<ClassificationInferenceOptionsDescriptor>
{
	internal ClassificationInferenceOptionsDescriptor(Action<ClassificationInferenceOptionsDescriptor> configure) => configure.Invoke(this);

	public ClassificationInferenceOptionsDescriptor() : base()
	{
	}

	private int? NumTopClassesValue { get; set; }
	private int? NumTopFeatureImportanceValuesValue { get; set; }
	private string? PredictionFieldTypeValue { get; set; }
	private string? ResultsFieldValue { get; set; }
	private string? TopClassesResultsFieldValue { get; set; }

	/// <summary>
	/// <para>
	/// Specifies the number of top class predictions to return. Defaults to 0.
	/// </para>
	/// </summary>
	public ClassificationInferenceOptionsDescriptor NumTopClasses(int? numTopClasses)
	{
		NumTopClassesValue = numTopClasses;
		return Self;
	}

	/// <summary>
	/// <para>
	/// Specifies the maximum number of feature importance values per document.
	/// </para>
	/// </summary>
	public ClassificationInferenceOptionsDescriptor NumTopFeatureImportanceValues(int? numTopFeatureImportanceValues)
	{
		NumTopFeatureImportanceValuesValue = numTopFeatureImportanceValues;
		return Self;
	}

	/// <summary>
	/// <para>
	/// Specifies the type of the predicted field to write. Acceptable values are: string, number, boolean. When boolean is provided 1.0 is transformed to true and 0.0 to false.
	/// </para>
	/// </summary>
	public ClassificationInferenceOptionsDescriptor PredictionFieldType(string? predictionFieldType)
	{
		PredictionFieldTypeValue = predictionFieldType;
		return Self;
	}

	/// <summary>
	/// <para>
	/// The field that is added to incoming documents to contain the inference prediction. Defaults to predicted_value.
	/// </para>
	/// </summary>
	public ClassificationInferenceOptionsDescriptor ResultsField(string? resultsField)
	{
		ResultsFieldValue = resultsField;
		return Self;
	}

	/// <summary>
	/// <para>
	/// Specifies the field to which the top classes are written. Defaults to top_classes.
	/// </para>
	/// </summary>
	public ClassificationInferenceOptionsDescriptor TopClassesResultsField(string? topClassesResultsField)
	{
		TopClassesResultsFieldValue = topClassesResultsField;
		return Self;
	}

	protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
	{
		writer.WriteStartObject();
		if (NumTopClassesValue.HasValue)
		{
			writer.WritePropertyName("num_top_classes");
			writer.WriteNumberValue(NumTopClassesValue.Value);
		}

		if (NumTopFeatureImportanceValuesValue.HasValue)
		{
			writer.WritePropertyName("num_top_feature_importance_values");
			writer.WriteNumberValue(NumTopFeatureImportanceValuesValue.Value);
		}

		if (!string.IsNullOrEmpty(PredictionFieldTypeValue))
		{
			writer.WritePropertyName("prediction_field_type");
			writer.WriteStringValue(PredictionFieldTypeValue);
		}

		if (!string.IsNullOrEmpty(ResultsFieldValue))
		{
			writer.WritePropertyName("results_field");
			writer.WriteStringValue(ResultsFieldValue);
		}

		if (!string.IsNullOrEmpty(TopClassesResultsFieldValue))
		{
			writer.WritePropertyName("top_classes_results_field");
			writer.WriteStringValue(TopClassesResultsFieldValue);
		}

		writer.WriteEndObject();
	}
}